package com.lnking.lnkingplace.controller;


import com.lnking.common.http.ReturnResult;
import com.lnking.lnkingplace.model.request.place.attractions.AttractionsAddRequest;
import com.lnking.lnkingplace.model.request.place.attractions.AttractionsSearchRequest;
import com.lnking.lnkingplace.model.request.place.attractions.AttractionsUpdateRequest;

import com.lnking.lnkingplace.service.IPlaceAttractionsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author sn
 * @since 2022-09-22
 */
@RestController
@Api(tags = "A级景区特有属性")
@RequestMapping("/place-attractions")
public class PlaceAttractionsController {

    @Autowired
    IPlaceAttractionsService placeAttractionsService;


    @ApiOperation("新增")
    @PostMapping("/add")
    public ReturnResult add(@RequestBody @Valid AttractionsAddRequest params) throws Exception {
        placeAttractionsService.add(params);
        return ReturnResult.success();
    }

    @ApiOperation("删除")
    @DeleteMapping("/{id}")
    public ReturnResult delete(@PathVariable("id") String id) {
        placeAttractionsService.removeById(id);
        return ReturnResult.success();
    }

    @ApiOperation("编辑")
    @PostMapping("/update")
    public ReturnResult update(@RequestBody @Valid AttractionsUpdateRequest params) throws Exception {
        placeAttractionsService.update(params);
        return ReturnResult.success();
    }

    @ApiOperation("查询列表")
    @GetMapping("/list")
    public ReturnResult getList(AttractionsSearchRequest params) {
        return ReturnResult.success(placeAttractionsService.pageList(params));
    }
}
